package cn.jn.lhm.statistics.schedule;

import cn.hutool.core.date.DateUtil;
import cn.jn.lhm.statistics.service.StatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author LHM
 * @Tips 热爱每一天，奋斗每一天
 * @date 2020/6/18 - 21:10
 */
@Component
@Slf4j
public class ScheduleTask {

    @Resource StatisticsService statisticsService;

    /**
     * 每天1点将前一天的数据添加进去
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void task(){
        log.info("执行定时任务 ：时间为" + DateUtil.yesterday() + "\t");
        statisticsService.countRegisterNumber(DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
    }
}
